package com.shop.trade.atom.atomsvc.impl;

import com.shop.common.model.ServiceBean;
import com.shop.common.model.param.trade.OrderCheckInput;
import com.shop.common.model.result.trade.OrderCheckOutput;
import com.shop.common.tmpl.BaseService;
import com.shop.trade.atom.atomsvc.IOrderCheckAtomSvc;
import com.shop.trade.atom.dao.OrderCheckMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 *
 * @author zhoulk
 * @date: 2019年04月15日  0:16
 */

@Service
public class OrderCheckAtom extends BaseService implements IOrderCheckAtomSvc {
    @Autowired
    OrderCheckMapper orderCheckMapper;

    @Override
    public ServiceBean<Integer> addOrderCheck(OrderCheckInput orderCheckInput) {
        int i = orderCheckMapper.insertSelective(orderCheckInput);
        if (opSuccess(i)) {
            return resultData(i);
        }
        return resultFailed();
    }

    @Override
    public ServiceBean<List<OrderCheckOutput>> qryOrderChecks(OrderCheckInput orderCheckInput) {
        List<OrderCheckOutput> list = orderCheckMapper.qryOrderChecks(orderCheckInput);
        if (!list.isEmpty()) {
            return resultData(list);
        }
        return resultFailed();
    }

    @Override
    public ServiceBean<OrderCheckOutput> qryOrderCheck(Integer id) {
        OrderCheckOutput orderCheckOutput = orderCheckMapper.selectByPrimaryKey(id);
        if (orderCheckOutput != null) {
            return resultData(orderCheckOutput);
        }
        return resultFailed();
    }

    @Override
    public ServiceBean<Integer> modOrderCheck(OrderCheckInput orderCheckInput) {
        int i = orderCheckMapper.updateByPrimaryKeySelective(orderCheckInput);
        if (opSuccess(i)) {
            return resultData(i);
        }
        return resultFailed();
    }
}
